package com.rzx.mybackend.controller.merchandise;

import com.rzx.mybackend.common.Result;
import com.rzx.mybackend.dto.BuyMerchandiseDTO;
import com.rzx.mybackend.entity.BuyMerchandise;
import com.rzx.mybackend.service.BuyMerchandiseService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * BuyMerchandiseController
 *
 * @author renzhexian
 * @date 2025/8/14
 */
@RestController
@RequestMapping("/buyMerchandise")
@RequiredArgsConstructor
public class BuyMerchandiseController {

    private final BuyMerchandiseService buyMerchandiseService;

    /**
     * 购买商品
     *
     * @param buyMerchandiseDTOList
     * @return
     */
    @PostMapping
    public Result buyMerchandise(@RequestBody List<BuyMerchandiseDTO> buyMerchandiseDTOList) {
        buyMerchandiseService.saveWithValidation(buyMerchandiseDTOList);
        return Result.success();
    }


}
